package model;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="familiamateriaprima")
@AssociationOverrides({
    @AssociationOverride(name="pk.familia",
            joinColumns = @JoinColumn(name="famcodigo")),
    @AssociationOverride(name="pk.materiaprima",
            joinColumns = @JoinColumn(name="matcodigo"))
})

public class FamiliaMateriaPrima implements java.io.Serializable{

    //private Familia familia;

    //private MateriaPrima materiaPrima;

    
    private FamiliaMateriaPrimaId pk = new FamiliaMateriaPrimaId();
    
    
    private int status;

    public FamiliaMateriaPrima() {
        
        
        
    }

    @EmbeddedId
    public FamiliaMateriaPrimaId getPk() {
        return pk;
    }

    
    public void setPk(FamiliaMateriaPrimaId pk) {
        this.pk = pk;
    }

    @Transient
    public Familia getFamilia(){
        return getPk().getFamilia();
    }
    
    public void setFamilia(Familia familia){
        getPk().setFamilia(familia);
    }
    
    @Transient
    public MateriaPrima getMateriaPrima(){
        return getPk().getMateriaprima();
    }
    
    public void setMateriaPrima(MateriaPrima materiaprima)
    {
        getPk().setMateriaprima(materiaprima);
    }
    
    @Column(name="fammatstatus")
    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
        
    public boolean equals(Object o){
        
        if(this == o)
            return true;
        if(o == null || getClass() != o.getClass())
            return false;
        
        FamiliaMateriaPrima that = (FamiliaMateriaPrima) o;
        
        if(getPk() != null ? !getPk().equals(that.getPk())
                : that.getPk() != null)
            return false;
        
        return true;
        
    }
    
    public int hashCode(){
        return (getPk() != null ? getPk().hashCode() : 0);
    }
}
